package com.prs.crm.dao.official.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.official.PersonalFileDao;
import com.prs.crm.domain.official.PersonalFile;

public class PersonalFileDaoImpl extends BaseDaoImpl<PersonalFile> implements PersonalFileDao{

	@SuppressWarnings("unchecked")
	@Override
	public Collection<PersonalFile> getRootPersonalFile() {
		Criteria criteria=this.getSession().createCriteria(PersonalFile.class);
		criteria.add(Restrictions.isNull("parent")).add(Restrictions.eq("type", "文件夹"));
		return criteria.list();
	}

	@Override
	public PersonalFile getPersonalFileById(Serializable id) {
		return this.getHibernateTemplate().get(PersonalFile.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PersonalFile> getAllPersonalFile() {
		Criteria criteria=this.getSession().createCriteria(PersonalFile.class);
		return criteria.list();
	}
}
